package framework.gui.panels;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;

/**
 * The panel that initializes and contains the buttons the
 * user will be interacting with.
 * 
 * @author Alex Duda
 */

@SuppressWarnings("serial")
public class BottomButtonPanel extends JPanel{
	
	private JButton start;
	private JButton step;
	private JButton stop;
	
	/**
	 * Initializes and sets up the bottom panel of buttons that
	 * the user will be interacting with.
	 * 
	 * @param listener the GridPanel that will be listening 
	 * to the buttons
	 */
	
	public BottomButtonPanel(GridPanel listener){
		//Set the layout of the panel
		setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
		
		//Initialize the buttons
		start = new JButton("Start");
		step = new JButton("Step");
		stop = new JButton("Stop");
		
		//Give each button its action command
		start.setActionCommand("start");
		step.setActionCommand("step");
		stop.setActionCommand("stop");
		
		//Set each button's listener (the GridPanel)
		start.addActionListener(listener);
		step.addActionListener(listener);
		stop.addActionListener(listener);
	
		//Set the initial buttons states
		setStoppedButtonStates();
		
		//Add the buttons to the panel
		add(start);
		add(step);
		add(stop);
	}

	/**
	 * Sets the enabled states for the buttons
	 * when the automata is stopped
	 */
	
	public void setStoppedButtonStates(){
		start.setEnabled(true);
		step.setEnabled(true);
		stop.setEnabled(false);
	}

	/**
	 * Sets the enabled states for the buttons
	 * when the automata is started
	 */
	
	public void setStartedButtonStates(){
		start.setEnabled(false);
		step.setEnabled(false);
		stop.setEnabled(true);
	}
	
}
